# 编译器设置
CXX = g++
CXXFLAGS = -std=c++17 -Wall -Wextra -I./

# 目标文件
TARGET = jvm

# 源文件
SRCS = main.cpp classfile/constant_pool.cpp classfile/member_info.cpp\
				rtda/local_vars.cpp rtda/operand_stack.cpp rtda/jvm_stack.cpp rtda/thread.cpp rtda/frame.cpp\
				instructions/base/instructions.cpp instructions/base/bytecode_reader.cpp instructions/base/branch_logic.cpp\
				instructions/comparisons/comparisons.cpp\
				instructions/constants/const.cpp instructions/constants/ipush.cpp\
				instructions/control/control.cpp\
				instructions/conversions/conversions.cpp\
				instructions/extended/extended.cpp\
				instructions/loads/aload.cpp instructions/loads/iload.cpp instructions/loads/fload.cpp instructions/loads/dload.cpp instructions/loads/lload.cpp\
				instructions/math/math_instructions.cpp\
				instructions/stack/dup.cpp instructions/stack/pop.cpp instructions/stack/swap.cpp\
				instructions/stores/istore.cpp instructions/stores/fstore.cpp instructions/stores/dstore.cpp instructions/stores/lstore.cpp instructions/stores/astore.cpp\
				instructions/instruction_factory.cpp\
				interpreter.cpp



# 目标文件
OBJS = $(SRCS:.cpp=.o)

# 依赖库
LIBS = -lzip

# 默认目标
all: $(TARGET)

# 链接
$(TARGET): $(OBJS)
	$(CXX) $(OBJS) -o $(TARGET) $(LIBS)

# 编译规则
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

# 清理
clean:
	rm -f $(OBJS) $(TARGET)

# 防止与同名文件冲突
.PHONY: all clean